cc.Class({
    extends: cc.Component,
    properties: {
        publicBet: cc.Node,
        totalLabel: cc.Label,
        myBetLabel: cc.Label,
        type: 0,
        data: {
            set(newValue) {
                let {total, myBet} = newValue
                if (total) { this.totalLabel.string = '' + total }
                if (myBet) { this.myBetLabel.string = '' + myBet + '倍' }
                this.publicBet.bet(null)
            }
        },
        lock: {
            default: false
        },
        nameLabel: cc.Label,
        rateLabel: cc.Label,
        configData: {
            set(newValue) {
                let {name, rate, type} = newValue
                this.type = type
                if (this.nameLabel)
                    this.nameLabel.string = name
                if (this.rateLabel)
                    this.rateLabel.string = `${rate}倍`
            }
        },
        count: 0,
    },

    onLoad() {
        this.publicBet = this.publicBet.getComponent('PublicBet')
        this.totalLabel.string = ''
        this.myBetLabel.string = ''
    },

    removePreBetInfo() {
        this.count = 0
    },

    bet() {
        if (!this.lock) {
            this.lock = true
            this.count++
            this.scheduleOnce(() => {
                this.lock = false
            }, 0.2)
        }
    },

    clear() {
        this.count = 0
        this.myBetLabel.string = ''
        this.totalLabel.string = ''
        this.publicBet.clear()
    },
})